﻿	<div class="easyui-layout" data-options="fit:true,border:false" style="overflow:hidden;padding:0;margin:0px auto">
	    <div data-options="region:'north',border:false" style="height:30px;background:#efefef;">
		<form id="sfe_pm_addplan_summary_form" method="post">
		<table>
		<tr><td>客户代码</td><td><input name="orgcode" type="text" size="15px"></td><td>客户名称</td><td><input name="orgname" type="text" size="15px"></td>
		<td><a id="sfe_pm_add_dialog_search" href="javascript:void(0)" onclick="addplan_formSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>&nbsp;<a id="sfe_pm_add_dialog_search" href="javascript:void(0)" onclick="addplan_formCancle();" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">清空</a></td></tr>
		</table></form>
		</div>
		<div data-options="region:'center',border:false">
			  <table id="sfe_pm_add_dialogsummary_datagrid"></table>
		</div>
	</div>
<script type="text/javascript">
var sfe_pm_add_dialogsummary_datagrid; //
$(function(){
     sfe_pm_add_dialogsummary_datagrid = $('#sfe_pm_add_dialogsummary_datagrid').datagrid({
			border : false,
			striped : true,
			nowrap:true,
			fitColumns : true,
			height:300,
			idField:'orgid',
			fit : true,
			pagination : true,
			columns : [[{
						field : 'orgid',
						width : 100,
						resizable : false,
						checkbox :true
					},{
						field : 'orgcode',
						title : '客户代码',
						width : 100,
						resizable : false,
						sortable:true
					}, {
						field : 'orgname',
						title : '客户名称',
						width : 200,
						resizable : false,
						sortable:true
					}]]
		});
	
	var p = sfe_pm_add_dialogsummary_datagrid.datagrid('getPager');
	$(p).pagination({
	    pageSize:10,
		pageList:[10,20],
		onSelectPage : function (pageNumber, pageSize) {
			addPlanDailogSummaryPage(pageNumber, pageSize);
		}
	});
     addPlanDailogSummary();
});

/**
* 获取页面summary数据
*/
function addPlanDailogSummary() {
		var variable = new Array('__methodName', '__token', 'pagename', 'actionname','__params');
		var value = new Array('wsActionJSON', token, 'p_sfeweekplanupdate', 'addplansummary',"{'currentdate':'" + pm_addplandialog_date +"','employeeid':'" + oval_user_search +"'}");
		var dataStr = getJsonData(variable, value);
		connectionServlet(dataStr, addPlanDailogSummaryReturn);
	};

function addPlanDailogSummaryReturn(data) {
	var str,tempResult,rowData;
    if(data.successflag == 'false') {
		return;
	}
	tempResult = data.result;
	if (typeof(tempResult) == 'undefined') {
		return;
	}
	
	if (typeof(tempResult.summaryhash) != 'undefined') {
		rowData = tempResult.summaryhash ;
	} else {
		str = '{"total":0,"rows":[]}';
		rowData =  $.parseJSON(str);
	}
	sfe_pm_add_dialogsummary_datagrid.datagrid('loadData',rowData);
}

/**
* summary翻页功能
*/
function addPlanDailogSummaryPage(pageNumber,pageSize) {
		if(typeof(pageNumber) == 'undefined' && typeof(pageSize) == 'undefined'){
		    var variable = new Array('__methodName', '__token', 'pagename', 'actionname','__params');
		    var value = new Array('wsActionJSON', token, 'p_sfeweekplanupdate', 'addplansummary','');
		}else{
		    var variable = new Array('__methodName', '__token', 'pagename', 'actionname','__params');
		    var value = new Array('wsActionJSON', token, 'p_sfeweekplanupdate', 'addplansummary',"{'employeeid':"+oval_user_search+",'jumppage':"+pageNumber+",'maxitem':"+pageSize+",'theendindex':"+ (pageNumber-1)*pageSize + "}");
		}
		var dataStr = getJsonData(variable, value);
		connectionServlet(dataStr, addPlanDailogSummaryPageReturn);
	};

function addPlanDailogSummaryPageReturn(data){
    var str,tempResult,rowsData;
    if (data.successflag == 'false') {
		return;
	}
	tempResult = data.result;
	if (typeof(tempResult) == 'undefined') {
		return;
	}
   if (typeof(tempResult.summaryhash) != 'undefined') {
		rowsData = tempResult.summaryhash ;
	} else {
		str = '{"total":0,"rows":[]}';
		rowsData =  $.parseJSON(str);
	}
 	sfe_pm_add_dialogsummary_datagrid.datagrid('loadData', rowsData);
}


/**
* 刷新
*/
function fbs_refresh(){
     getVisiptplanShowData();
}

/**
  * 搜索功能
  */
function addplan_formSearch() {
    searchFlag = true;
    var orgcode,orgname;
	orgcode = $("#sfe_pm_addplan_summary_form input[name='orgcode']").val();
	orgname = $("#sfe_pm_addplan_summary_form input[name='orgname']").val();
    var params = "{'orgcode':'"+orgcode+"','orgname':'"+orgname+"','employeeid':'"+oval_user_search+"'}";
	var variable = new Array('__methodName', '__token', 'pagename', 'actionname', '__params');
	var value = new Array('wsActionJSON', token, 'p_sfeweekplanupdate', 'addplansummary', params);
	var dataStr = getJsonData(variable, value);
	connectionServlet(dataStr, addPlanDailogSummaryReturn);
}

/**
* 清空搜索输入框里的内容
*/
function addplan_formCancle(){
     $("#sfe_pm_addplan_summary_form input[name='orgcode']").val('');
	 $("#sfe_pm_addplan_summary_form input[name='orgname']").val('');
	 addPlanDailogSummary();
}
</script>
